package YAVMM::Guest;
use Moose;
use MooseX::Storage;
use MooseX::Method::Signatures;

our $VERSION = '0.01';

use YAVMM::Types;

with Storage ('format' => 'JSON');

has 'name' => (
    is       => 'rw',
    isa      => 'Str',
    required => 1,
    documentation => 'Unique name for the guest',
);

has 'cpu' => (
    is       => 'rw',
    isa      => 'Str',
    default  => 'qemu64',
    documentation => 'The cpu type. Default: qemu64',
);

has 'smp' => (
    is       => 'rw',
#    isa      => 'PositiveInt',
    isa      => 'Int',
    default  => 1,
    documentation => 'Number of virtual CPUs',
);

has 'ram' => (
    is       => 'rw',
#    isa      => 'PositiveInt',
    isa      => 'Int',
    default  => 256,
    documentation => 'Amount of RAM (MB)'
);

has 'clock_base' => (
    is       => 'rw',
    isa      => 'Str',
    default  => 'utc',
    documentation => 'Specify base as utc or localtime to let the RTC start at the current UTC or local time, respectively. localtime is required for correct date in MS-DOS or Windows.',
);

has 'usb' => (
    is       => 'rw',
    isa      => 'Bool',
    default  => 1,
    documentation => 'Enable the USB driver',
);

has 'usbdevices' => (
    is       => 'rw',
    isa      => 'ArrayRef[YAVMM::USBDevice]',
    default  => sub { [] },
);

has 'drives' => (
    is       => 'rw',
    isa      => 'ArrayRef[YAVMM::Drive]',
    default  => sub { [] },
);

has 'nics' => (
    is       => 'rw',
    isa      => 'ArrayRef[YAVMM::NIC]',
    default  => sub { [] },
);

has 'boot' => (
    is       => 'rw',
    isa      => 'Str',
    default  => 'c',
);

has 'console' => (
    is       => 'rw',
    does     => 'YAVMM::Console',
);

has 'status' => (
    is       => 'rw',
    isa      => 'Str',
    default  => '',
);

#method sorted_attributes {
sub sorted_attributes {
    my $self = shift;
    return $self->_sort_attributes(['name', 'cpu', 'smp', 'ram']);
}

with 'YAVMM::SortedAttributes';

sub TO_JSON { return $_[0]->pack; }

__PACKAGE__->meta->make_immutable;
1;
